import { ElMessageBox } from "element-plus";
const version = import.meta.env.VITE_APP_VERSION || import.meta.env.VERSION;
console.log("版本号:", version,import.meta.env.VERSION);

let cacheVersion = localStorage.getItem("cacheVersion");
console.log("缓存版本:", cacheVersion);
if (!cacheVersion) {
  localStorage.setItem("cacheVersion", version);
} else if (cacheVersion !== version) {
  // 确认对话框
  ElMessageBox.confirm("有新版本，请刷新页面？", "版本更新提示", {
    confirmButtonText: "更新",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      console.log("用户点击确定");
      location.reload();
      localStorage.setItem("cacheVersion", version);
    })
    .catch(() => {
      console.log("用户点击取消");
    });
}
